switch: Hide internal structure from a11y
authorMatthias Clasen <mclasen@redhat.com>
Wed, 21 Oct 2020 18:55:13 +0000 (14:55 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 21 Oct 2020 18:55:13 +0000 (14:55 -0400)
According to section 7.1 of WAI-ARIA, the switch role
has the "Children presentational" characteristic, which
indicates that children should not be represented in
the a11y tree.

gtk/gtkswitch.c

index a178672595f3f9612042e0702dfe49d975cf2f7b..bb681d9123093548d6366f5aa26889610e0f207d 100644 (file)
@@ -651,13 +651,21 @@ gtk_switch_init (GtkSwitch *self)
                                   gtk_switch_allocate);
   gtk_widget_set_layout_manager (GTK_WIDGET (self), layout);
 
-  self->on_image = gtk_image_new_from_icon_name ("switch-on-symbolic");
+  self->on_image = g_object_new (GTK_TYPE_IMAGE,
+                                 "accessible-role", GTK_ACCESSIBLE_ROLE_NONE,
+                                 "icon-name", "switch-on-symbolic",
+                                 NULL);
   gtk_widget_set_parent (self->on_image, GTK_WIDGET (self));
 
-  self->off_image = gtk_image_new_from_icon_name ("switch-off-symbolic");
+  self->off_image = g_object_new (GTK_TYPE_IMAGE,
+                                  "accessible-role", GTK_ACCESSIBLE_ROLE_NONE,
+                                  "icon-name", "switch-off-symbolic",
+                                  NULL);
   gtk_widget_set_parent (self->off_image, GTK_WIDGET (self));
 
-  self->slider = gtk_gizmo_new ("slider", NULL, NULL, NULL, NULL, NULL, NULL);
+  self->slider = gtk_gizmo_new_with_role ("slider",
+                                          GTK_ACCESSIBLE_ROLE_NONE,
+                                          NULL, NULL, NULL, NULL, NULL, NULL);
   gtk_widget_set_parent (self->slider, GTK_WIDGET (self));
 
   gtk_accessible_update_state (GTK_ACCESSIBLE (self),